//
//  LocationManager.h
//  CarLife
//
//  Created by yu on 2018/3/13.
//  Copyright © 2018年 jpas. All rights reserved.
//

#import <Foundation/Foundation.h>

#import <AMapFoundationKit/AMapFoundationKit.h>
#import <AMapLocationKit/AMapLocationKit.h>
#import <AMapSearchKit/AMapSearchAPI.h>

//////////////////定位/////////////////
// 定位成功的回调
typedef void(^LocationInfoBlock)(double lat, double lng, AMapLocationReGeocode *reGeocode);
// 定位权限状态的改变
typedef void(^ChangedAuthStatusBlock)(CLAuthorizationStatus status);

@interface LocationManager : NSObject<AMapLocationManagerDelegate>

@property (nonatomic, strong) AMapLocationManager *locationManager;
@property (nonatomic, copy) LocationInfoBlock locationInfoBlock;
@property (nonatomic, copy) ChangedAuthStatusBlock changedAuthStatusBlock;


+ (LocationManager *)shareLocationManager;

+ (void)startUpdatingLocation;
+ (void)stopUpdatingLocation;

/**
 获取坐标位置
 */
+ (void)getLocationInfo:(LocationInfoBlock)locationInfoBlock;

/**
 实时检测定位权限状态的改变
 */
+ (void)getChangedAuthStatus:(ChangedAuthStatusBlock)changedAuthStatusBlock;
/**
 检测定位权限是否可用
 */
+ (BOOL)isLocationEnabled;

// 设置其他属性...
// 设置期望定位精度
//+ (void)setDesiredAccuracy:(CLLocationAccuracy)desiredAccuracy;

@end


/////////////<<<<<<<逆地理解析>>>>>>>/////////////
typedef void(^ReGeocodeFailBlock)(NSString *errcode);
typedef void(^ReGeocodeBlock)(AMapReGeocode *reGeocode);

@class RegeocodeRequest;
@protocol RegeocodeRequestDelegate <NSObject>

- (void)regeocodeRequestComplete:(RegeocodeRequest*)request;

@end
//------------------------------------
@interface RegeocodeRequest : NSObject<AMapSearchDelegate>

@property (nonatomic, strong) AMapSearchAPI *search;
@property (nonatomic, copy) ReGeocodeBlock reGeocodeBlock;
@property (nonatomic, copy) ReGeocodeFailBlock reGeocodeFailBlock;
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, weak) id<RegeocodeRequestDelegate> delegate;

- (void)start;

@end

//------------------------------------

@interface ReGeocodeManager : NSObject<RegeocodeRequestDelegate>

@property (nonatomic, copy, readonly) NSMutableArray<RegeocodeRequest*>* regeocodeRequests;

+ (ReGeocodeManager *)shareReGeocodeManager;

+ (void)searchReGeocodeWithCoordinate:(CLLocationCoordinate2D)coordinate
                       reGeocodeBlock:(ReGeocodeBlock)reGeocodeBlock
                   reGeocodeFailBlock:(ReGeocodeFailBlock)reGeocodeFailBlock;

@end


